<template>
  <div>
    <h2>权限管理</h2><br>
    <el-row>
      <el-col :span="7"
        >角色名称：<el-input
          v-model="searchForm.role"
          style="width: 240px"
          placeholder="请输入用户账号"
      /></el-col>
      <el-col :span="7"
        >院区：<el-input
          v-model="searchForm.campur"
          style="width: 240px"
          placeholder="请输入用户姓名"
      /></el-col>
      <el-col :span="3"
        ><el-button type="primary" round>查询</el-button></el-col
      >
    </el-row>
    <br>
    <div style="margin-left: 260px">
      <vxe-toolbar>
        <template #buttons>
          <vxe-button
            status="primary"
            icon="vxe-icon-square-plus"
            @click="adddialogVisible = true"
            >新增</vxe-button
          >
        </template>
      </vxe-toolbar>
    </div>
    <div style="display: flex; justify-content: center">
      <el-table :data="tableData" height="300" border style="width: 60%">
        <el-table-column
          prop="role"
          label="角色名称"
          width="100"
          align="center"
        />
        <el-table-column
          prop="roleDescription"
          label="角色描述"
          width="200"
          align="center"
        />
        <el-table-column
          prop="campur"
          label="院区"
          width="177"
          align="center"
        />
        <el-table-column prop="state" label="状态" width="100" align="center" />
        <el-table-column label="操作" width="200" header-align="center" />
      </el-table>
    </div>
  </div>
  <!-- 新增对话框 -->
  <el-dialog v-model="adddialogVisible" title="新增权限" width="600">
    <el-form
      ref="ruleFormRef"
      style="max-width: 600px"
      :model="ruleForm"
      :rules="rules"
      label-width="auto"
      class="demo-ruleForm"
      :size="formSize"
      status-icon
    >
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="部门名称" prop="depart">
            <el-input v-model="ruleForm.depart" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="角色院区" prop="campur">
            <el-input v-model="ruleForm.campur" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="职位名称" prop="title">
            <el-input v-model="ruleForm.title" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-form-item label="状态" prop="state">
        <el-radio-group v-model="ruleForm.state">
          <el-radio value="1">启用</el-radio>
          <el-radio value="0">关闭</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-row :gutter="20">
        <el-col :span="12">
          <el-form-item label="权限" prop="power">
            <el-input v-model="ruleForm.power" />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <el-row >
      <div style="height: 100px"></div>
    </el-row>
    <template #footer>
      <div class="dialog-footer" style="text-align: center">
        <el-button type="primary" @click="doAdd"> 保存 </el-button>
      </div>
    </template>
  </el-dialog>
</template>
  
  
<script setup>
import { ref, reactive } from "vue";
const adddialogVisible = ref(false);
const tableData = [
  {
    role: "Tom",
    roleDescription: "",
    campur: "1",
    state: "1",
  },
  {
    role: "Tom",
    roleDescription: "",
    campur: "1",
    state: "1",
  },
  {
    role: "Tom",
    roleDescription: "",
    campur: "1",
    state: "1",
  },
  {
    role: "Tom",
    roleDescription: "",
    campur: "1",
    state: "1",
  },
  {
    role: "Tom",
    roleDescription: "",
    campur: "1",
    state: "1",
  },
  {
    role: "Tom",
    roleDescription: "",
    campur: "1",
    state: "1",
  },
  {
    role: "Tom",
    roleDescription: "",
    campur: "1",
    state: "1",
  },
  {
    role: "Tom",
    roleDescription: "",
    campur: "1",
    state: "1",
  },
];
const doAdd = async () => {
  adddialogVisible.value = false;
};

const formSize = ref("default");
const ruleFormRef = ref();
const searchForm = reactive({});
const ruleForm = reactive({
  username: "",
  password: "",
  name: "",
  sex: "",
  idCard: "",
  phone: "",
  birthday: "",
  title: "",
  role: "",
  campur: "",
  department: "",
  state: "",
});

const rules = reactive({
  // name: [
  //   { required: true, message: "Please input Activity name", trigger: "blur" },
  //   { min: 3, max: 5, message: "Length should be 3 to 5", trigger: "blur" },
  // ],
  region: [
    {
      required: true,
      message: "Please select Activity zone",
      trigger: "change",
    },
  ],
  count: [
    {
      required: true,
      message: "Please select Activity count",
      trigger: "change",
    },
  ],
  date1: [
    {
      type: "date",
      required: true,
      message: "Please pick a date",
      trigger: "change",
    },
  ],
  date2: [
    {
      type: "date",
      required: true,
      message: "Please pick a time",
      trigger: "change",
    },
  ],
  type: [
    {
      type: "array",
      required: true,
      message: "Please select at least one activity type",
      trigger: "change",
    },
  ],
  resource: [
    {
      required: true,
      message: "Please select activity resource",
      trigger: "change",
    },
  ],
  desc: [
    { required: true, message: "Please input activity form", trigger: "blur" },
  ],
});

const submitForm = async (formEl) => {
  if (!formEl) return;
  await formEl.validate((valid, fields) => {
    if (valid) {
      console.log("submit!");
    } else {
      console.log("error submit!", fields);
    }
  });
};

const resetForm = (formEl) => {
  if (!formEl) return;
  formEl.resetFields();
};

const options = Array.from({ length: 10000 }).map((_, idx) => ({
  value: `${idx + 1}`,
  label: `${idx + 1}`,
}));
</script>
  
  
<style scoped>
</style>